package com.apestech.framework.db;

import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.Array;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Date;
import java.sql.NClob;
import java.sql.Ref;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.RowId;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.SQLXML;
import java.sql.Statement;
import java.sql.Time;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Map;

import com.apestech.framework.db.callback.FieldTitle;
import com.apestech.framework.db.callback.ReadRowCallbackHandler;
import com.apestech.framework.db.callback.ResultOutPut;
import com.apestech.framework.json.JSON;
import com.apestech.framework.json.JSONArray;
import com.apestech.framework.json.JSONObject;
import com.apestech.framework.metadata.SqlMetaData;
import com.apestech.framework.sql.condition.ConditionMap;
import com.apestech.framework.util.DateUtil;
import com.apestech.framework.util.StringUtil;

import javax.servlet.http.HttpServletResponse;


/**
 * 指针式查询结果，操作工具
 * 1)默认支持一次循环，循环方式 while(rs.next())方式循环，可结合toRowJson方法将行数据转成JSONObject进行操作加工使用，建议每个循环体如变量使用完毕，要注意及时置为null
 * 2)如果需要数据多次反复使用，可使用toJson方法将全部数据转成JSONArray模式，之后再多次循环使用，建议常规使用1）方式
 * 3)定位某一条之后，如果字段名方式调用获取某一行值信息时，如果所带字段名为空值，将会报错
 * 4)增加判断是否为合法字段名方法 isField
 * @author hupo
 *
 */
public class SqlResultSet extends StringUtil implements ResultSet {

	private ResultSet rs;
	private SqlMetaData rsmd;
	private JSONArray rslist=null;
	private SqlTemplate cn;
	private FieldFormat format;
	private String fields;
	private ConditionMap conParam;
	private FieldTitle fieldTitle;
	private String timestampField;

	public SqlResultSet() throws SQLException{
	}

	public SqlResultSet(ResultSet rs) throws SQLException{
		if(rs==null){
			throw new SQLException(getMessage("SqlResultSet_isNull","查询结果集不允许为空值 "));
		}
		this.rs=rs;
		rsmd=new SqlMetaData(rs.getMetaData());
		this.rs.setFetchSize(100);
	}

	public SqlResultSet(ResultSet rs, SqlTemplate cn) throws SQLException{
		if(rs==null){
			throw new SQLException(getMessage("SqlResultSet_isNull","查询结果集不允许为空值 "));
		}
		this.rs=rs;
		rsmd=new SqlMetaData(rs.getMetaData());
		this.rs.setFetchSize(100);
		this.cn=cn;
	}

	public SqlTemplate getSqlTemplate(){
		return this.cn;
	}

	public void setFormat(Format formatMap) throws Exception {
		if(conParam==null) return;
		this.format = new FieldFormat();
		this.format.setFormat(formatMap, false, conParam.isBmath());
	}

	public void setTimestampField(String timestampField) {
		this.timestampField = timestampField;
	}

	public ConditionMap getConParam() {
		return conParam;
	}

	public void setConParam(ConditionMap conParam) {
		this.conParam = conParam;
	}

	public void setFieldTitle(FieldTitle fieldTitle) {
		this.fieldTitle = fieldTitle;
	}

	/**
	 * 获取数据，支持ReadRowBack（读数前，读每一行数据，读数后三种状态自定义事件）
	 * @param rowback
	 * @return
	 * @throws SQLException
	 */
	public JSONArray getData(ReadRowCallbackHandler rowback) throws SQLException{
		Object obj=rowback.beforeRead(this.rslist);
		while(this.rs.next()){
			rowback.readRow(obj, this.rs);
		}
		return (JSONArray) rowback.AfterRead(obj);
	}

	public Object getFieldValue(String field) throws Exception {
		if(this.format==null){
			this.format=new FieldFormat();
			if(conParam!=null){
				this.format.setTimestampField(timestampField);
				this.format.setFormat(conParam.getFormat(), conParam.isXls(), conParam.isBmath());
			}
		}
		if(conParam!=null) {
			Object v=rs.getObject(field);
			return this.format.getValue(field, v, conParam.getHtw());
		} else{
			Object value=rs.getObject(field);
			if(value!=null){
				String sclass=value.getClass().getName().toUpperCase();
				if(sclass.indexOf("CLOB")>=0){
					value=castClobToString((Clob) value);
				} else if(value instanceof oracle.sql.TIMESTAMP){
					oracle.sql.TIMESTAMP time=(oracle.sql.TIMESTAMP)value;
					value=new Timestamp(time.timestampValue().getTime());
				}
			}
			return value;
		}
	}

	/**
	 * 获取当前行数据JSON,如无行数据，返回null
	 * @return
	 * @throws SQLException
	 */
	public JSONObject toRowJson() throws Exception{
		return toRowJson(null);
	}

	/**
	 * 获取当前行数据JSON,如无行数据，返回null
	 * @return
	 * @throws SQLException
	 */
	public JSONObject toRowJson(String field) throws Exception{
		if("".equals(field) || field==null){
			if(fields==null) fields = this.rsmd.getFieldString();
			field=fields+";";
		} else {
			field=";"+field+";";
		}
		JSONObject json = new JSONObject();
		String[] flist=field.split(";");
		int len=flist.length;
		for(int i=0; i<len; i++){
			String fieldname=flist[i];
			if(fieldname!=null){
				if(isField(fieldname)){
					json.put(getFieldName(fieldname), getFieldValue(fieldname));
				}
			}
		}
		if(conParam!=null && conParam.getOutputWeb()!=null && conParam.getSqlCallback()!=null){
			json=conParam.getSqlCallback().toJSON(conParam.getFromtab(), json);
		}
		json.put("SYS_RID", rs.getRow());
		return json;
	}

	private String getFieldName(String fieldname){
		if(conParam!=null && conParam.isJpa()){
			fieldname=getJPAName(fieldname);
		}
		return fieldname;
	}

	public ArrayList<Object> toRowArray() throws Exception{
		return toRowArray(getColumns());
	}

	public String toRowJsonStr() throws Exception{
		return toRowJsonStr(null);
	}

	public String toRowJsonStr(String field) throws Exception{
		if("".equals(field) || field==null){
			if(fields==null) fields = this.rsmd.getFieldString();
			field=fields+";";
		} else {
			field=";"+field+";";
		}
		StringBuffer s=new StringBuffer();
		s.append("{");
		String[] flist=field.split(";");
		int len=flist.length;
		int j=0;
		for(int i=0; i<len; i++){
			String fieldname=flist[i];
			if(fieldname!=null){
				if(isField(fieldname)){
					Object v=getFieldValue(fieldname);
					boolean bdot=false;
					if(j>0){
						s.append(",");
					}
					if(v instanceof String || v instanceof java.util.Date || v instanceof oracle.sql.TIMESTAMP || v instanceof java.sql.Timestamp){
						bdot=true;
						if(!(v instanceof String)){
							v= DateUtil.dateTimeToStr((java.util.Date)v);
						}
					}
					s.append("\""+fieldname+"\":");
					if(bdot){
						s.append("\""+v+"\"");
					} else {
						s.append(StringUtil.castToString(v));
					}
					j++;
				}
			}
		}
		if(s.length()>1){
			s.append(",");
			s.append("\"SYS_RID\":");
			s.append(rs.getRow());
		}
		s.append("}");
//		if(conParam!=null && conParam.getOutputWeb()!=null && conParam.getSqlCallback()!=null){
//			JSONObject json=new JSONObject(s.toString());
//			json=conParam.getSqlCallback().toJSON(conParam.getFromtab(), json);
//			return JSON.toJSONString(json);
//		}
		return s.toString();
	}

	public void toRowJsonBuf(HttpServletResponse response, String charset) throws Exception{
		toRowJsonBuf(null, response, charset);
	}

	public void toRowJsonBuf(String field, HttpServletResponse response, String charset) throws Exception{
		if("".equals(field) || field==null){
			if(fields==null) fields = this.rsmd.getFieldString();
			field=fields+";";
		} else {
			field=";"+field+";";
		}
		response.getOutputStream().write("{".getBytes(charset));
		String[] flist=field.split(";");
		int len=flist.length;
		int j=0;
		for(int i=0; i<len; i++){
			String fieldname=flist[i];
			if(fieldname!=null){
				if(isField(fieldname)){
					Object v=getFieldValue(fieldname);
					if(v!=null){
						boolean bdot=false;
						if(j>0){
							response.getOutputStream().write(",".getBytes(charset));
						}
						if(v instanceof String || v instanceof java.util.Date || v instanceof oracle.sql.TIMESTAMP || v instanceof java.sql.Timestamp){
							bdot=true;
							if(!(v instanceof String)){
								v= DateUtil.dateTimeToStr((java.util.Date)v);
							}
						}
						response.getOutputStream().write(("\""+fieldname+"\":").getBytes(charset));
						if(bdot){
							response.getOutputStream().write(("\""+v+"\"").getBytes(charset));
						} else {
							response.getOutputStream().write(StringUtil.castToString(v).getBytes(charset));
						}
						j++;
					}
				}
			}
		}
		response.getOutputStream().write(",".getBytes(charset));
		response.getOutputStream().write("\"SYS_RID\":".getBytes(charset));
		response.getOutputStream().write(castToString(rs.getRow()).getBytes(charset));

		response.getOutputStream().write("}".getBytes(charset));
//		if(conParam!=null && conParam.getOutputWeb()!=null && conParam.getSqlCallback()!=null){
//			JSONObject json=new JSONObject(s.toString());
//			json=conParam.getSqlCallback().toJSON(conParam.getFromtab(), json);
//			return JSON.toJSONString(json);
//		}
	}

	public ArrayList<Object> toRowArray(String[] flist) throws Exception{
		ArrayList<Object> list=new ArrayList<Object>();
		int len=flist.length;
		for(int i=0; i<len; i++){
			String fieldname=flist[i];
			if(!"".equals(fieldname)){
				Object val=getFieldValue(fieldname);
				list.add(val);
			}
		}
		return list;
	}

	public ArrayList<Object> toHeadArray() throws SQLException{
		ResultSetMetaData rsmd=rs.getMetaData();
		int len=rsmd.getColumnCount();
		ArrayList<Object> list=new ArrayList<Object>();
		for(int i=0; i<len; i++){
			String field=rsmd.getColumnName(i+1);
			list.add(field);
		}
		return list;
	}

	public JSONArray toHeadJSONArray() throws SQLException {
		ResultSetMetaData rsmd=rs.getMetaData();
		int len=rsmd.getColumnCount();
		JSONArray list=new JSONArray();
		for(int i=0; i<len; i++){
			String field=rsmd.getColumnName(i+1);
			String title=field;
			try {
				if(fieldTitle!=null){
					title=fieldTitle.getTitle(this.conParam.getFieldTable(field), field);
					if(title==null) title=field;
				}
				list.add(new JSONObject("{\"field\":\""+field+"\",\"title\":\""+title+"\"}"));
			} catch (Exception e) {
				throw new SQLException(e);
			}
		}
		return list;
	}

	/**
	 * 一次性操作，将全部数据转成JSON
	 * @return
	 * @throws SQLException
	 */
	public JSONArray toJSON() throws Exception{
		return toJSON(null);
	}

	/**
	 * 一次性操作，将全部数据根据指定字段转成JSON
	 * @param field
	 * @return
	 * @throws SQLException
	 */
	public JSONArray toJSON(String field) throws Exception{
		if(this.rslist==null && this.rs!=null){
			this.rslist=new JSONArray();
			int count=0;
			while(this.rs.next() && count<100000){
				count++;
				this.rslist.add(toRowJson(field));
			}
		}
		return this.rslist;
	}

	/**
	 * 获取列个数
	 * @throws SQLException
	 */
	public int getColumnCount() throws SQLException{
		return this.rsmd.getColumnCount();
	}

	/**
	 * 获取字段列表
	 * @return
	 */
	public String[] getColumns(){
		return this.rsmd.getColumns();
	}

	/**
	 * 判断字段名是否有效
	 */
	public boolean isField(String field){
		if(field==null){
			return false;
		}
		if("".equals(field.trim())){
			return false;
		}
		if(fields==null) fields = this.rsmd.getFieldString();
		fields=fields+";";
		if(fields.indexOf(";"+field+";")<0){
			return false;
		} else {
			return true;
		}
	}

	/*原生方法*/
	public boolean isWrapperFor(Class<?> arg0) throws SQLException {
		return this.rs.isWrapperFor(arg0);
	}

	public <T> T unwrap(Class<T> arg0) throws SQLException {
		return this.rs.unwrap(arg0);
	}

	public boolean absolute(int arg0) throws SQLException {
		return this.rs.absolute(arg0);
	}

	public void afterLast() throws SQLException {
		this.rs.afterLast();
	}

	public void beforeFirst() throws SQLException {
		this.rs.beforeFirst();
	}

	public void cancelRowUpdates() throws SQLException {
		this.rs.cancelRowUpdates();
	}

	public void clearWarnings() throws SQLException {
		this.rs.clearWarnings();
	}

	public void close() throws SQLException {
		if(this.rs!=null) this.rs.close();
	}

	public void deleteRow() throws SQLException {
		this.rs.deleteRow();
	}

	public int findColumn(String arg0) throws SQLException {
		return this.rs.findColumn(arg0);
	}

	public boolean first() throws SQLException {
		return this.rs.first();
	}

	public Array getArray(int arg0) throws SQLException {
		return this.rs.getArray(arg0);
	}

	public Array getArray(String arg0) throws SQLException {
		return this.rs.getArray(arg0);
	}

	public InputStream getAsciiStream(int arg0) throws SQLException {
		return this.rs.getAsciiStream(arg0);
	}

	public InputStream getAsciiStream(String arg0) throws SQLException {
		return this.rs.getAsciiStream(arg0);
	}

	public BigDecimal getBigDecimal(int arg0) throws SQLException {
		return this.rs.getBigDecimal(arg0);
	}

	public BigDecimal getBigDecimal(String arg0) throws SQLException {
		return this.rs.getBigDecimal(arg0);
	}

	@SuppressWarnings("deprecation")
	public BigDecimal getBigDecimal(int arg0, int arg1) throws SQLException {
		return this.rs.getBigDecimal(arg0, arg1);
	}

	@SuppressWarnings("deprecation")
	public BigDecimal getBigDecimal(String arg0, int arg1) throws SQLException {
		return this.rs.getBigDecimal(arg0, arg1);
	}

	public InputStream getBinaryStream(int arg0) throws SQLException {
		return this.rs.getBinaryStream(arg0);
	}

	public InputStream getBinaryStream(String arg0) throws SQLException {
		return this.rs.getBinaryStream(arg0);
	}

	public Blob getBlob(int arg0) throws SQLException {
		return this.rs.getBlob(arg0);
	}

	public Blob getBlob(String arg0) throws SQLException {
		return this.rs.getBlob(arg0);
	}

	public boolean getBoolean(int arg0) throws SQLException {
		return this.rs.getBoolean(arg0);
	}

	public boolean getBoolean(String arg0) throws SQLException {
		return this.rs.getBoolean(arg0);
	}

	public byte getByte(int arg0) throws SQLException {
		return this.rs.getByte(arg0);
	}

	public byte getByte(String arg0) throws SQLException {
		return this.rs.getByte(arg0);
	}

	public byte[] getBytes(int arg0) throws SQLException {
		return this.rs.getBytes(arg0);
	}

	public byte[] getBytes(String arg0) throws SQLException {
		return this.rs.getBytes(arg0);
	}

	public Reader getCharacterStream(int arg0) throws SQLException {
		return this.rs.getCharacterStream(arg0);
	}

	public Reader getCharacterStream(String arg0) throws SQLException {
		return this.rs.getCharacterStream(arg0);
	}

	public Clob getClob(int arg0) throws SQLException {
		return this.rs.getClob(arg0);
	}

	public Clob getClob(String arg0) throws SQLException {
		return this.rs.getClob(arg0);
	}

	public int getConcurrency() throws SQLException {
		return this.rs.getConcurrency();
	}

	public String getCursorName() throws SQLException {
		return this.rs.getCursorName();
	}

	public Date getDate(int arg0) throws SQLException {
		return this.rs.getDate(arg0);
	}

	public Date getDate(String arg0) throws SQLException {
		return this.rs.getDate(arg0);
	}

	public Date getDate(int arg0, Calendar arg1) throws SQLException {
		return this.rs.getDate(arg0, arg1);
	}

	public Date getDate(String arg0, Calendar arg1) throws SQLException {
		return this.rs.getDate(arg0, arg1);
	}

	public double getDouble(int arg0) throws SQLException {
		return this.rs.getDouble(arg0);
	}

	public double getDouble(String arg0) throws SQLException {
		return this.rs.getDouble(arg0);
	}

	public int getFetchDirection() throws SQLException {
		return this.rs.getFetchDirection();
	}

	public int getFetchSize() throws SQLException {
		return this.rs.getFetchSize();
	}

	public float getFloat(int arg0) throws SQLException {
		return this.rs.getFloat(arg0);
	}

	public float getFloat(String arg0) throws SQLException {
		return this.rs.getFloat(arg0);
	}

	public int getHoldability() throws SQLException {
		return this.rs.getHoldability();
	}

	public int getInt(int arg0) throws SQLException {
		return this.rs.getInt(arg0);
	}

	public int getInt(String arg0) throws SQLException {
		return this.rs.getInt(arg0);
	}

	public long getLong(int arg0) throws SQLException {
		return this.rs.getLong(arg0);
	}

	public long getLong(String arg0) throws SQLException {
		return this.rs.getLong(arg0);
	}

	public ResultSetMetaData getMetaData() throws SQLException {
		return this.rs.getMetaData();
	}

	public Reader getNCharacterStream(int arg0) throws SQLException {
		return this.rs.getNCharacterStream(arg0);
	}

	public Reader getNCharacterStream(String arg0) throws SQLException {
		return this.rs.getNCharacterStream(arg0);
	}

	public NClob getNClob(int arg0) throws SQLException {
		return this.rs.getNClob(arg0);
	}

	public NClob getNClob(String arg0) throws SQLException {
		return this.rs.getNClob(arg0);
	}

	public String getNString(int arg0) throws SQLException {
		return this.rs.getNString(arg0);
	}

	public String getNString(String arg0) throws SQLException {
		return this.rs.getNString(arg0);
	}

	public Object getObject(int arg0) throws SQLException {
		return this.rs.getObject(arg0);
	}

	public Object getObject(String arg0) throws SQLException {
		return this.rs.getObject(arg0);
	}

	public Object getObject(int arg0, Map<String, Class<?>> arg1)
			throws SQLException {
		return this.rs.getObject(arg0, arg1);
	}

	public Object getObject(String arg0, Map<String, Class<?>> arg1)
			throws SQLException {
		return this.rs.getObject(arg0, arg1);
	}

	public <T> T getObject(int arg0, Class<T> arg1) throws SQLException {
		return this.rs.getObject(arg0, arg1);
	}

	public <T> T getObject(String arg0, Class<T> arg1) throws SQLException {
		return this.rs.getObject(arg0, arg1);
	}

	public Ref getRef(int arg0) throws SQLException {
		return this.rs.getRef(arg0);
	}

	public Ref getRef(String arg0) throws SQLException {
		return this.rs.getRef(arg0);
	}

	public int getRow() throws SQLException {
		return this.rs.getRow();
	}

	public RowId getRowId(int arg0) throws SQLException {
		return this.rs.getRowId(arg0);
	}

	public RowId getRowId(String arg0) throws SQLException {
		return this.rs.getRowId(arg0);
	}

	public SQLXML getSQLXML(int arg0) throws SQLException {
		return this.rs.getSQLXML(arg0);
	}

	public SQLXML getSQLXML(String arg0) throws SQLException {
		return this.rs.getSQLXML(arg0);
	}

	public short getShort(int arg0) throws SQLException {
		return this.rs.getShort(arg0);
	}

	public short getShort(String arg0) throws SQLException {
		return this.rs.getShort(arg0);
	}

	public Statement getStatement() throws SQLException {
		return this.rs.getStatement();
	}

	public String getString(int arg0) throws SQLException {
		return this.rs.getString(arg0);
	}

	public String getString(String arg0) throws SQLException {
		return this.rs.getString(arg0);
	}

	public Time getTime(int arg0) throws SQLException {
		return this.rs.getTime(arg0);
	}

	public Time getTime(String arg0) throws SQLException {
		return this.rs.getTime(arg0);
	}

	public Time getTime(int arg0, Calendar arg1) throws SQLException {
		return this.rs.getTime(arg0, arg1);
	}

	public Time getTime(String arg0, Calendar arg1) throws SQLException {
		return this.rs.getTime(arg0, arg1);
	}

	public Timestamp getTimestamp(int arg0) throws SQLException {
		return this.rs.getTimestamp(arg0);
	}

	public Timestamp getTimestamp(String arg0) throws SQLException {
		return this.rs.getTimestamp(arg0);
	}

	public Timestamp getTimestamp(int arg0, Calendar arg1) throws SQLException {
		return this.rs.getTimestamp(arg0, arg1);
	}

	public Timestamp getTimestamp(String arg0, Calendar arg1)
			throws SQLException {
		return this.rs.getTimestamp(arg0, arg1);
	}

	public int getType() throws SQLException {
		return this.rs.getType();
	}

	public URL getURL(int arg0) throws SQLException {
		return this.rs.getURL(arg0);
	}

	public URL getURL(String arg0) throws SQLException {
		return this.rs.getURL(arg0);
	}

	@SuppressWarnings("deprecation")
	public InputStream getUnicodeStream(int arg0) throws SQLException {
		return this.rs.getUnicodeStream(arg0);
	}

	@SuppressWarnings("deprecation")
	public InputStream getUnicodeStream(String arg0) throws SQLException {
		return this.rs.getUnicodeStream(arg0);
	}

	public SQLWarning getWarnings() throws SQLException {
		return this.rs.getWarnings();
	}

	public void insertRow() throws SQLException {
		this.rs.insertRow();
	}

	public boolean isAfterLast() throws SQLException {
		return this.rs.isAfterLast();
	}

	public boolean isBeforeFirst() throws SQLException {
		return this.rs.isBeforeFirst();
	}

	public boolean isClosed() throws SQLException {
		return this.rs.isClosed();
	}

	public boolean isFirst() throws SQLException {
		return this.rs.isFirst();
	}

	public boolean isLast() throws SQLException {
		return this.rs.isLast();
	}

	public boolean last() throws SQLException {
		return this.rs.last();
	}

	public void moveToCurrentRow() throws SQLException {
		this.rs.moveToCurrentRow();
	}

	public void moveToInsertRow() throws SQLException {
		this.rs.moveToInsertRow();
	}

	public boolean next() throws SQLException {
		if(this.rs==null) return false;
		return this.rs.next();
	}

	public boolean previous() throws SQLException {
		return this.rs.previous();
	}

	public void refreshRow() throws SQLException {
		this.rs.refreshRow();
	}

	public boolean relative(int arg0) throws SQLException {
		return this.rs.relative(arg0);
	}

	public boolean rowDeleted() throws SQLException {
		return this.rs.rowDeleted();
	}

	public boolean rowInserted() throws SQLException {
		return this.rs.rowInserted();
	}

	public boolean rowUpdated() throws SQLException {
		return this.rs.rowUpdated();
	}

	public void setFetchDirection(int arg0) throws SQLException {
		this.rs.setFetchDirection(arg0);
	}

	public void setFetchSize(int arg0) throws SQLException {
		this.rs.setFetchSize(arg0);
	}

	public void updateArray(int arg0, Array arg1) throws SQLException {
		this.rs.updateArray(arg0, arg1);
	}

	public void updateArray(String arg0, Array arg1) throws SQLException {
		this.rs.updateArray(arg0, arg1);
	}

	public void updateAsciiStream(int arg0, InputStream arg1)
			throws SQLException {
		this.rs.updateAsciiStream(arg0, arg1);
	}

	public void updateAsciiStream(String arg0, InputStream arg1)
			throws SQLException {
		this.rs.updateAsciiStream(arg0, arg1);
	}

	public void updateAsciiStream(int arg0, InputStream arg1, int arg2)
			throws SQLException {
		this.rs.updateAsciiStream(arg0, arg1);
	}

	public void updateAsciiStream(String arg0, InputStream arg1, int arg2)
			throws SQLException {
		this.rs.updateAsciiStream(arg0, arg1, arg2);
	}

	public void updateAsciiStream(int arg0, InputStream arg1, long arg2)
			throws SQLException {
		this.rs.updateAsciiStream(arg0, arg1, arg2);
	}

	public void updateAsciiStream(String arg0, InputStream arg1, long arg2)
			throws SQLException {
		this.rs.updateAsciiStream(arg0, arg1, arg2);
	}

	public void updateBigDecimal(int arg0, BigDecimal arg1) throws SQLException {
		this.rs.updateBigDecimal(arg0, arg1);
	}

	public void updateBigDecimal(String arg0, BigDecimal arg1)
			throws SQLException {
		this.rs.updateBigDecimal(arg0, arg1);
	}

	public void updateBinaryStream(int arg0, InputStream arg1)
			throws SQLException {
		this.rs.updateBinaryStream(arg0, arg1);
	}

	public void updateBinaryStream(String arg0, InputStream arg1)
			throws SQLException {
		this.rs.updateBinaryStream(arg0, arg1);
	}

	public void updateBinaryStream(int arg0, InputStream arg1, int arg2)
			throws SQLException {
		this.rs.updateBinaryStream(arg0, arg1, arg2);
	}

	public void updateBinaryStream(String arg0, InputStream arg1, int arg2)
			throws SQLException {
		this.rs.updateBinaryStream(arg0, arg1, arg2);
	}

	public void updateBinaryStream(int arg0, InputStream arg1, long arg2)
			throws SQLException {
		this.rs.updateBinaryStream(arg0, arg1, arg2);
	}

	public void updateBinaryStream(String arg0, InputStream arg1, long arg2)
			throws SQLException {
		this.rs.updateBinaryStream(arg0, arg1, arg2);
	}

	public void updateBlob(int arg0, Blob arg1) throws SQLException {
		this.rs.updateBlob(arg0, arg1);
	}

	public void updateBlob(String arg0, Blob arg1) throws SQLException {
		this.rs.updateBlob(arg0, arg1);
	}

	public void updateBlob(int arg0, InputStream arg1) throws SQLException {
		this.rs.updateBlob(arg0, arg1);
	}

	public void updateBlob(String arg0, InputStream arg1) throws SQLException {
		this.rs.updateBlob(arg0, arg1);
	}

	public void updateBlob(int arg0, InputStream arg1, long arg2)
			throws SQLException {
		this.rs.updateBlob(arg0, arg1, arg2);
	}

	public void updateBlob(String arg0, InputStream arg1, long arg2)
			throws SQLException {
		this.rs.updateBlob(arg0, arg1, arg2);
	}

	public void updateBoolean(int arg0, boolean arg1) throws SQLException {
		this.rs.updateBoolean(arg0, arg1);
	}

	public void updateBoolean(String arg0, boolean arg1) throws SQLException {
		this.rs.updateBoolean(arg0, arg1);
	}

	public void updateByte(int arg0, byte arg1) throws SQLException {
		this.rs.updateByte(arg0, arg1);
	}

	public void updateByte(String arg0, byte arg1) throws SQLException {
		this.rs.updateByte(arg0, arg1);
	}

	public void updateBytes(int arg0, byte[] arg1) throws SQLException {
		this.rs.updateBytes(arg0, arg1);
	}

	public void updateBytes(String arg0, byte[] arg1) throws SQLException {
		this.rs.updateBytes(arg0, arg1);
	}

	public void updateCharacterStream(int arg0, Reader arg1)
			throws SQLException {
		this.rs.updateCharacterStream(arg0, arg1);
	}

	public void updateCharacterStream(String arg0, Reader arg1)
			throws SQLException {
		this.rs.updateCharacterStream(arg0, arg1);
	}

	public void updateCharacterStream(int arg0, Reader arg1, int arg2)
			throws SQLException {
		this.rs.updateCharacterStream(arg0, arg1, arg2);
	}

	public void updateCharacterStream(String arg0, Reader arg1, int arg2)
			throws SQLException {
		this.rs.updateCharacterStream(arg0, arg1, arg2);
	}

	public void updateCharacterStream(int arg0, Reader arg1, long arg2)
			throws SQLException {
		this.rs.updateCharacterStream(arg0, arg1, arg2);
	}

	public void updateCharacterStream(String arg0, Reader arg1, long arg2)
			throws SQLException {
		this.rs.updateCharacterStream(arg0, arg1, arg2);
	}

	public void updateClob(int arg0, Clob arg1) throws SQLException {
		this.rs.updateClob(arg0, arg1);
	}

	public void updateClob(String arg0, Clob arg1) throws SQLException {
		this.rs.updateClob(arg0, arg1);
	}

	public void updateClob(int arg0, Reader arg1) throws SQLException {
		this.rs.updateClob(arg0, arg1);
	}

	public void updateClob(String arg0, Reader arg1) throws SQLException {
		this.rs.updateClob(arg0, arg1);
	}

	public void updateClob(int arg0, Reader arg1, long arg2)
			throws SQLException {
		this.rs.updateClob(arg0, arg1, arg2);
	}

	public void updateClob(String arg0, Reader arg1, long arg2)
			throws SQLException {
		this.rs.updateClob(arg0, arg1, arg2);
	}

	public void updateDate(int arg0, Date arg1) throws SQLException {
		this.rs.updateDate(arg0, arg1);
	}

	public void updateDate(String arg0, Date arg1) throws SQLException {
		this.rs.updateDate(arg0, arg1);
	}

	public void updateDouble(int arg0, double arg1) throws SQLException {
		this.rs.updateDouble(arg0, arg1);
	}

	public void updateDouble(String arg0, double arg1) throws SQLException {
		this.rs.updateDouble(arg0, arg1);
	}

	public void updateFloat(int arg0, float arg1) throws SQLException {
		this.rs.updateFloat(arg0, arg1);
	}

	public void updateFloat(String arg0, float arg1) throws SQLException {
		this.rs.updateFloat(arg0, arg1);
	}

	public void updateInt(int arg0, int arg1) throws SQLException {
		this.rs.updateInt(arg0, arg1);
	}

	public void updateInt(String arg0, int arg1) throws SQLException {
		this.rs.updateInt(arg0, arg1);
	}

	public void updateLong(int arg0, long arg1) throws SQLException {
		this.rs.updateLong(arg0, arg1);
	}

	public void updateLong(String arg0, long arg1) throws SQLException {
		this.rs.updateLong(arg0, arg1);
	}

	public void updateNCharacterStream(int arg0, Reader arg1)
			throws SQLException {
		this.rs.updateNCharacterStream(arg0, arg1);
	}

	public void updateNCharacterStream(String arg0, Reader arg1)
			throws SQLException {
		this.rs.updateNCharacterStream(arg0, arg1);
	}

	public void updateNCharacterStream(int arg0, Reader arg1, long arg2)
			throws SQLException {
		this.rs.updateNCharacterStream(arg0, arg1, arg2);
	}

	public void updateNCharacterStream(String arg0, Reader arg1, long arg2)
			throws SQLException {
		this.rs.updateNCharacterStream(arg0, arg1, arg2);
	}

	public void updateNClob(int arg0, NClob arg1) throws SQLException {
		this.rs.updateNClob(arg0, arg1);
	}

	public void updateNClob(String arg0, NClob arg1) throws SQLException {
		this.rs.updateNClob(arg0, arg1);
	}

	public void updateNClob(int arg0, Reader arg1) throws SQLException {
		this.rs.updateNClob(arg0, arg1);
	}

	public void updateNClob(String arg0, Reader arg1) throws SQLException {
		this.rs.updateNClob(arg0, arg1);
	}

	public void updateNClob(int arg0, Reader arg1, long arg2)
			throws SQLException {
		this.rs.updateNClob(arg0, arg1, arg2);
	}

	public void updateNClob(String arg0, Reader arg1, long arg2)
			throws SQLException {
		this.rs.updateNClob(arg0, arg1, arg2);
	}

	public void updateNString(int arg0, String arg1) throws SQLException {
		this.rs.updateNString(arg0, arg1);
	}

	public void updateNString(String arg0, String arg1) throws SQLException {
		this.rs.updateNString(arg0, arg1);
	}

	public void updateNull(int arg0) throws SQLException {
		this.rs.updateNull(arg0);
	}

	public void updateNull(String arg0) throws SQLException {
		this.rs.updateNull(arg0);
	}

	public void updateObject(int arg0, Object arg1) throws SQLException {
		this.rs.updateObject(arg0, arg1);
	}

	public void updateObject(String arg0, Object arg1) throws SQLException {
		this.rs.updateObject(arg0, arg1);
	}

	public void updateObject(int arg0, Object arg1, int arg2)
			throws SQLException {
		this.rs.updateObject(arg0, arg1, arg2);
	}

	public void updateObject(String arg0, Object arg1, int arg2)
			throws SQLException {
		this.rs.updateObject(arg0, arg1, arg2);
	}

	public void updateRef(int arg0, Ref arg1) throws SQLException {
		this.rs.updateRef(arg0, arg1);
	}

	public void updateRef(String arg0, Ref arg1) throws SQLException {
		this.rs.updateRef(arg0, arg1);
	}

	public void updateRow() throws SQLException {
		this.rs.updateRow();
	}

	public void updateRowId(int arg0, RowId arg1) throws SQLException {
		this.rs.updateRowId(arg0, arg1);
	}

	public void updateRowId(String arg0, RowId arg1) throws SQLException {
		this.rs.updateRowId(arg0, arg1);
	}

	public void updateSQLXML(int arg0, SQLXML arg1) throws SQLException {
		this.rs.updateSQLXML(arg0, arg1);
	}

	public void updateSQLXML(String arg0, SQLXML arg1) throws SQLException {
		this.rs.updateSQLXML(arg0, arg1);
	}

	public void updateShort(int arg0, short arg1) throws SQLException {
		this.rs.updateShort(arg0, arg1);
	}

	public void updateShort(String arg0, short arg1) throws SQLException {
		this.rs.updateShort(arg0, arg1);
	}

	public void updateString(int arg0, String arg1) throws SQLException {
		this.rs.updateString(arg0, arg1);
	}

	public void updateString(String arg0, String arg1) throws SQLException {
		this.rs.updateString(arg0, arg1);
	}

	public void updateTime(int arg0, Time arg1) throws SQLException {
		this.rs.updateTime(arg0, arg1);
	}

	public void updateTime(String arg0, Time arg1) throws SQLException {
		this.rs.updateTime(arg0, arg1);
	}

	public void updateTimestamp(int arg0, Timestamp arg1) throws SQLException {
		this.rs.updateTimestamp(arg0, arg1);
	}

	public void updateTimestamp(String arg0, Timestamp arg1)
			throws SQLException {
		this.rs.updateTimestamp(arg0, arg1);
	}

	public boolean wasNull() throws SQLException {
		return this.rs.wasNull();
	}
	/*原生方法*/

}
